# Table B5: Covid-19 Death Effects on Asian Hate Crimes

rm(list = ls())

setwd('/path/to/replication/')

library(data.table)
library(estimatr)
library(texreg)

load('./data/panel_month_dummies.RData')

out_death_feb_simple <- lm_robust(hc_pc_asians ~ covid2*excess_deaths_feb_d, data=panel, se_type='stata',
                                  clusters = panelvar)

if (!file.exists('./output/out_death_feb.RData') &
    !file.exists('./output/out_death_feb_con.RData') &
    !file.exists('./output/out_death_feb_con_trend.RData') &
    !file.exists('./output/out_death_feb_con_trend_all.RData')) {
  source('./code/tableB5reg.R')
}

out_death_feb <- get(load('./output/out_death_feb.RData'))
out_death_feb_con <- get(load('./output/out_death_feb_con.RData'))
out_death_feb_con_trend <- get(load('./output/out_death_feb_con_trend.RData'))
out_death_feb_con_trend_all <- get(load('./output/out_death_feb_con_trend_all.RData'))

tableb5 <- texreg(list(out_death_feb_simple, out_death_feb, out_death_feb_con, out_death_feb_con_trend, out_death_feb_con_trend_all),
       include.ci = FALSE,
       include.adjrs = FALSE, include.rmse = FALSE,
       stars = c(0.001, 0.01, 0.05), digits = 5,
       custom.coef.map = list('excess_deaths_feb_d' = 'Excess deaths', 'covid2'= 'After Jan, 2020', 
                              'covid2:excess_deaths_feb_d' = 'After Jan, 2020 x Excess deaths',
                              'covid_death' = 'After Jan, 2020 x Excess deaths'),
       symbol = "\\circ",
       caption = "Covid-19 Death Effects on Asian Hate Crimes",
       caption.above = TRUE)

write(tableb5, file.path('./tableB5.tex'))